using UnityEngine;
using System.Collections;

public class StoneBehaviour : Equipable
{
    StoneItem m_Item;
    public bool beingUsed = false;
    /// <summary>
    /// 
    /// </summary>
    /// <param name="item">Item del que viene, se guarda la referencia para sacarlo del inventario al tirar la piedr</param>
    public StoneBehaviour(StoneItem item)
    {
        m_UseRange = 40;
        m_Item = item;
    }
    public override void Use(Actor targetActor, Actor owner)
    {
    }
    public override void Use(Vector3 targetPos, Actor owner)
    {
        if (beingUsed) return;
        if (Vector3.Distance(owner.transform.position, targetPos) <= m_UseRange)
        {
            GameObject prefab = PrefabManager.GetInstance().GetPrefab("stoneeffect");
            StoneEffect stoneeffect = ((GameObject)GameObject.Instantiate(prefab)).GetComponent<StoneEffect>();
            stoneeffect.StartEffect(owner.transform.position, targetPos,this);

            beingUsed = true;
            //m_Item.RemoveFromInventory();

            //owner.UnEquip(this);
        }
        else
        {
            Debug.Log("out of range");
        }
    }
}
